Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Padding bytes may not be zero. #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uunicorn
Copy link

Fixes #18

See pkcs1pad2 in JS_RSA.js:
...
while(n > 2) { // random non-zero pad
x[0] = 0;
while(x[0] == 0) rng.nextBytes(x);
ba[--n] = x[0];
}
...

Fixes schlatterbeck#18

See pkcs1pad2 in JS_RSA.js:
...
  while(n > 2) { // random non-zero pad
    x[0] = 0;
    while(x[0] == 0) rng.nextBytes(x);
    ba[--n] = x[0];
  }
...
@kukenc
Copy link

kukenc commented Mar 24, 2020

It works for me. GJ

@lalmeras
Copy link

lalmeras commented Nov 6, 2023

This fix allows to get rid of Unexpected response, looking for MultiChallenge or Portal messages. As I understand it, theses messages are triggered when os.urandom emits b'\0' values. As this char is a separator, it must not be present in random value.

Surely because I currently run the script with python2.7 (not sure), I need to use:

r.append (bytes(bytearray([int(x.encode('hex'), 16) % 255 + 1 for x in os.urandom (n)])))

instead of proposal:

r.append (bytes([x % 255 + 1 for x in os.urandom (n)]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Authentication intermittently fails due to incorrect padding.
3 participants